package com.chinacoal.microservice.mapper;

import com.baomidou.mybatisplus.mapper.BaseMapper;
import com.baomidou.mybatisplus.plugins.Page;
import com.chinacoal.microservice.pojo.CcmsSmartleasingContract;
import org.apache.ibatis.annotations.Param;

import java.util.Date;
import java.util.List;

/**
 * @author zhuliang
 * @version V1.0
 * @Description: 运维管理-合同管理-mybatis-plus接口类
 * @date 2020-11-16 10：08
 */
public interface CcmsSmartleasingContractMapper extends BaseMapper<CcmsSmartleasingContract> {

    /**
     * @Description: 退租的修改方法
     * @author zhuliang
     * @date 2020/11/17 11:47
     */
    void updateByRentCancellation(@Param("lastUpdatedBy") Integer lastUpdatedBy,
                                  @Param("lastUpdateDate") Date lastUpdateDate,
                                  @Param("contractActualEndTime") Date contractActualEndTime,
                                  @Param("causeDescription") String causeDescription,
                                  @Param("contractState") Byte contractState,
                                  @Param("actualRefund") Long actualRefund,
                                  @Param("refundInstructions") String refundInstructions,
                                  @Param("pkContractId") String pkContractId,
                                  @Param("fkRoomStatusId") String fkRoomStatusId,
                                  @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                                  @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 批量删除
     * @author zhuliang
     * @date 2020/11/18 14:07
     */
    void updateToDeleteById(@Param("lastUpdatedBy") Integer lastUpdatedBy,
                            @Param("lastUpdateDate") Date lastUpdateDate,
                            @Param("deleteSign") Byte deleteSign,
                            @Param("pkContractId") String[] pkContractId,
                            @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                            @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 条件查询带分页
     * @author zhuliang
     * @date 2020/11/18 14:07
     */
    List<CcmsSmartleasingContract> getContractByCondition(@Param("tenantType") Integer tenantType,
                                                          @Param("inputString") String inputString,
                                                          @Param("contactPhone") String contactPhone,
                                                          @Param("idcardNumber") String idcardNumber,
                                                          @Param("firstDate") Date firstDate,
                                                          @Param("endDate") Date endDate,
                                                          @Param("contractState") Integer contractState,
                                                          @Param("contractNumber") String contractNumber,
                                                          Page<CcmsSmartleasingContract> toPage,
                                                          @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                                                          @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 查询所有的合同信息带分页
     * @author zhuliang
     * @date 2020/11/20 11:05
     */
    List<CcmsSmartleasingContract> getAllByPage(Page<CcmsSmartleasingContract> toPage,
                                                @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                                                @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 根据合同id查询合同信息
     * @author zhuliang
     * @date 2020/11/20 11:36
     */
    CcmsSmartleasingContract getContractById(@Param("pkContractId") String pkContractId,
                                             @Param("fkPropertyCompanyId") String fkPropertyCompanyId,
                                             @Param("fkAdministrativeOfficeId") String fkAdministrativeOfficeId);

    /**
     * @Description: 查询要删除的合同,已审核和已中止的数量
     * @author zhuliang
     * @date 2020/11/24 16:16
     */
    String getCountByContractState(@Param("pkContractId") String[] pkContractId);

    /**
     * @Description: 查询超过合同时间的所有合同信息
     * @author zhuliang
     * @date 2020/11/25 9:54
     */
    List<CcmsSmartleasingContract> getCountByDate(@Param("toDate") Date toDate);

    /**
     * @Description: 查询合同中是否有这个房间信息
     * @author zhuliang
     * @date 2020/11/26 11:35
     */
    String getCountByRoomId(@Param("fkRoomId") String[] fkRoomId);

    /**
     * @Description: 查询所有合同状态的生效的合同id
     * @author zhuliang
     * @date 2020/11/27 14:49
     */
    List<CcmsSmartleasingContract> getAllIdByContractState();

    /**
     * @Description: 查询不是空置中的房间，在合同表中的数量
     * @author zhuliang
     * @date 2020/12/4 10:34
     */
    String[] getByRoom(@Param("fkRoomId") String fkRoomId);

    /**
     * @Description: 微信端-我的房间查询
     * @author zhuliang
     * @date 2020/12/22 17:21
     */
    List<CcmsSmartleasingContract> getAllByRoom(@Param("contactPhone") String contactPhone);

    /**
     * @Description: 查询所有已审核待生效的合同
     * @author zhuliang
     * @date 2021/1/27 17:17
     */
    List<CcmsSmartleasingContract> getEffectiveContract();

    /**
     * @Description: 合同审核的时间验证
     * @author zhuliang
     * @date 2021/1/28 17:56
     */
    String timeVerification(@Param("time") Date time,
                            @Param("fkRoomId") String fkRoomId);

    /**
     * @Description: 合同新增或修改，查询是否需要改房间状态
     * @author zhuliang
     * @date 2021/1/29 9:33
     */
    String determineRoomStatus(@Param("fkRoomId") String fkRoomId);

    /**
     * @Description: 查询合同删除后，需要修改房间状态的房间id
     * @author zhuliang
     * @date 2021/1/29 10:28
     */
    String[] inquireRoomId(@Param("pkContractId") String[] pkContractId);

    /**
     * @Description: 根据费用id查询开票方式
     * @author zhuliang
     * @date 2021/3/25 19:30
     */
    String queryBillingMethod(@Param("pkExpenseManagId") String pkExpenseManagId);

//    CcmsSmartleasingContract getOneById(@Param("pkContractId") String pkContractId);
}
